#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("mine.in" , "r" , stdin);
	freopen("mine.out" , "w" , stdout);
	int m , n;
	cin >> m >> n;
	char a[105][105];
	for(int i = 0 ; i < m ; i++){
		scanf("%s" , a[i]);
	}
	for(int i = 0 ; i < m ; i++){
		for(int j = 0 ; j < n ; j++){
			int sum = 0;
			if(a[i][j] == '?'){
				if(i >= 1 && j >= 1 && a[i - 1][j - 1] == '*'){
					sum++;
				}
				if(i >= 1 && a[i - 1][j] == '*'){
					sum++;
				}
				if(j >= 1 && a[i][j - 1] == '*'){
					sum++;
				}
				if(i <= m - 2 && j <= n - 2 && a[i + 1][j + 1] == '*'){
					sum++;
				}
				if(i <= m - 2 && a[i + 1][j] == '*'){
					sum++;
				}
				if(j <= n - 2 && a[i][j + 1] == '*'){
					sum++;
				}
				if(i >= 1 && j <= n - 2 && a[i - 1][j + 1] == '*'){
					sum++;
				}
				if(i <= m - 2 && j >= 1 && a[i + 1][j - 1] == '*'){
					sum++;
				}
				cout << sum;
				continue;
			}
			cout << '*';
		}
		cout << endl;
	}
	return 0;
}